package com.example.custcomsumer.service;

import com.example.custcomsumer.entity.BigEvent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

import java.util.List;

@Service
public class CustBehaveService {

    @Autowired
    private RestTemplate restTemplate;

    public List<BigEvent> selectNormal(int currentPage, int pageSize) {
        return restTemplate.getForObject("http://custom-behave-provider/big-event-provider/selectNormal/" + currentPage + "/" + pageSize, List.class);
    }

    public List<BigEvent> selectAbnormal(int currentPage, int pageSize) {
        return restTemplate.getForObject("http://custom-behave-provider/big-event-provider/selectAbnormal/" + currentPage + "/" + pageSize, List.class);
    }

    public Integer getNormalSum() {
        return restTemplate.getForObject("http://custom-behave-provider/big-event-provider/getNormalSum", Integer.class);
    }

    public Integer getAbnormalSum() {
        return restTemplate.getForObject("http://custom-behave-provider/big-event-provider/getAbnormalSum", Integer.class);
    }

    public void setAbnormal(int id) {
        restTemplate.getForObject("http://custom-behave-provider/big-event-provider/setAbnormal/" + id, void.class);
    }

    public void cancelAbnormal(int id) {
        restTemplate.getForObject("http://custom-behave-provider/big-event-provider/cancelAbnormal/" + id, void.class);
    }

}
